<?php

function t(){

}
class Persion {
    public $name;
    public $age = 21;
    public $school = '北京大学';
    public $bool = true;
    public $arr = array('testkey'=>'testval');
    public $null = NULL;

    //以下是不可以用初始值
    //public $test = 1+1;
    //public $test = t();
    //public $test = new Persion();
    //public $test = fopen('01.php','ab');

    /**
     * 方法的定义
     * 和涵数的定义一致
     */
    function say(){
        echo ' My name is '.$this->name;
        print('<br>');
        #echo ' My age is '.$this->age;
        $this->sayMyAge();
    }
    function setAge($age=22){
        $this->age=$age;
    }
    public function sayMyAge(){
        echo ' My age is '.$this->age;
    }
}

$lisi = new Persion();
print_r($lisi);
print('<br>');
#var_dump($lisi->name);
echo '李四的年龄:'.$lisi->age.'岁','<br>';
echo '李四的毕业学校:'.$lisi->school,'<br>';
print_r($lisi->arr);
print('<br>');
$lisi->name = 'lisi';//修改属性值
echo $lisi->name;
//php4以后被public取代，不再建议使用
//var $str = 'stringval';
print('<br>');
$lisi->say();
print('<br>');
$lisi->setAge(25);
$lisi->sayMyAge();






?>